package com.paginasenlanube.view;

import java.io.Serializable;
import java.util.ArrayList;

import java.util.List;

import java.util.Properties;



import com.google.gson.Gson;
import com.paginasenlanube.model.Image;
import com.paginasenlanube.model.Website;


public class Config implements Serializable{
	
	
	private static final  long serialVersionUID = 1L;
	private List<List<String>> list = new ArrayList<List<String>>();
	private List<String> templates = new ArrayList<String>();
	private List<String> colorPalettes = new ArrayList<String>();
	private List<String> backgroundThemes = new ArrayList<String>();
	private List<String> dataTypeTemplates = new ArrayList<String>();
	private List<String> archiveTemplates = new ArrayList<String>();
	private List<String> imageGalTemplates = new ArrayList<String>();

	
	public Config(){
		
	}
	
	public void setData(Properties myProps,Website  website){
				 		  		 
		   
		 String[] templatesData = myProps.getProperty("templates").split(",");
		  templates.clear();
		   for(String t : templatesData){  
			   templates.add(t);					
		   }
		   
		   if(templatesData.length>0 && website.getDesign().getTemplate().isEmpty()){
			   website.getDesign().setTemplate(templatesData[0]);
		   }
		   
		   String[] colorPalettesData = myProps.getProperty(website.getDesign().getTemplate()+".colorPalettes").split(",");
		   colorPalettes.clear();
		   for(String p : colorPalettesData){	  
			   colorPalettes.add(p);
		   }
		   
		   if(colorPalettesData.length>0 && website.getDesign().getColorPalette().isEmpty()){
			   website.getDesign().setColorPalette(( colorPalettesData[0]));
		   }
		   
		   String[] backgroundThemesData = myProps.getProperty(website.getDesign().getColorPalette()+".backgroundThemes").split(",");
		   backgroundThemes.clear();
		   for(String b : backgroundThemesData){  
			   backgroundThemes.add(b);
		   }
		   
		   String[] dataTypeData = myProps.getProperty("dataType.templates").split(",");
		   dataTypeTemplates.clear();
		   for(String b : dataTypeData){  
			   dataTypeTemplates.add(b);
		   }
		   
		   String[] archiveData = myProps.getProperty("archive.templates").split(",");
		   archiveTemplates.clear();
		   for(String b : archiveData){  
			   archiveTemplates.add(b);
		   }
		   
		   String[] imageGalData = myProps.getProperty("imageGal.templates").split(",");
		   imageGalTemplates.clear();
		   for(String b : imageGalData){  
			   imageGalTemplates.add(b);
		   }
		
	}
	
	public void setTemplates(List<String> templates) {
		this.templates = templates;
	}
	
	public List<String> getTemplates() {
		return templates;
	}

	public void setColorPalettes(List<String> colorPalettes) {
		this.colorPalettes = colorPalettes;
	}
	
	public List<String> getColorPalettes() {
		return colorPalettes;
	}


	public void setBackgroundThemes(List<String> backgroundThemes) {
		this.backgroundThemes = backgroundThemes;
	}
	
	public List<String> getBackgroundThemes() {
		return backgroundThemes;
	}
	
	public List<String> getDataTypeTemplates() {
		return dataTypeTemplates;
	}

	public void setDataTypeTemplates(List<String> dataTypeTemplates) {
		this.dataTypeTemplates = dataTypeTemplates;
	}
	
	public List<String> getArchiveTemplates() {
		return archiveTemplates;
	}

	public void setArchiveTemplates(List<String> archiveTemplates) {
		this.archiveTemplates = archiveTemplates;
	}
	
	public List<String> getImageGalTemplates() {
		return imageGalTemplates;
	}

	public void setImageGalTemplates(List<String> imageGalTemplates) {
		this.imageGalTemplates = imageGalTemplates;
	}


	@Override
	public String toString() {
	   list.clear();
	   list.add(templates);
	   list.add(colorPalettes);
	   list.add(backgroundThemes);
	   list.add(dataTypeTemplates);
	   list.add(archiveTemplates);
	   list.add(imageGalTemplates);

	   Gson gson = new Gson();
	   String configJson = gson.toJson(list);
	   return configJson;
	
	}

	








}
